/***************************************************************************//**
* \file cy_mixer.h
* \version 1.0
*
* Provides an API declaration of the mixer driver.
*
********************************************************************************
* \copyright
* Copyright 2016-2024, Cypress Semiconductor Corporation
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*     http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*******************************************************************************/

/**
* \addtogroup group_mixer
* \{
* The Mixer driver provides APIs to configure the audio mixer.
*
* The functions and other declarations used in this driver are in cy_mixer.h.
* You can include cy_pdl.h (ModusToolbox only) to get access to all functions
* and declarations in the PDL.
*
* Features:
* * Combines multiple PCM source streams into a single PCM destination stream.
* * Typically, a PCM source stream consists of a repetition of a PCM sample pattern
*   in memory. The number of repetitions is dynamic; that is, at the stream start,
*   the stream end may not be known. Typically, a system event activates (starts)
*   a PCM source stream and another system event deactivates (ends) a PCM source
*   stream.
* * A PCM source stream can be gain/volume controlled.
* * A PCM source stream can be faded in (typically at the stream start) and faded
*   out (typically just before the stream end).
* * A PCM source stream sample frequency has a specific ratio with respect to the
*   PCM destination stream sample frequency: 0.5x, 1x, 2x, 3x, 4x, 6x, 8x, 12x.
*   The mixer upscales (2x, 3x, ..., 12x) or down-scales (0.5x) the PCM source stream
*   to the PCM destination stream.
* * The PCM destination stream can be gain/volume controlled.
* * The PCM destination stream can be faded in and faded out.
* * Fixed PCM sample formatting: 16-bit pairs.
* * I2S transmitter with master and slave functionality. See the device datasheet to
*   confirm whether this feature is supported.
*
* \section group_mixer_configuration Configuration Considerations
*
* To set up an audio mixer, initialize the mixer destination and one or more
* source streams.
*
* The mixer destination can be configured by providing all of the parameters
* in the \ref cy_stc_mixer_dst_config_t structure. Then call the
* \ref Cy_Mixer_DestinationInit function to initialize the mixer destination.
* Additional APIs are provided to configure and control the mixer destination
* after initialization.
*
* A mixer source can be configured by providing all of the parameters in the
* \ref cy_stc_mixer_src_config_t structure. Then call the \ref Cy_Mixer_SourceInit
* function to initialize the mixer source. Additional APIs are provided to
* configure and control the mixer source after initialization.
*
* For the mixer to operate, the destination and one or more sources must be
* enabled and activated. Typically, enabling a source is done at mixer
* initialization time and activating/deactivating a source is done at a finer
* grain, based on system events that activate (start) and/or deactivate (end)
* PCM source streams.
*
* Destination initialization example:
* \snippet mixer/snippet/main.c snippet_Cy_Mixer_DestinationInit
*
* Source initialization example:
* \snippet mixer/snippet/main.c snippet_Cy_Mixer_SourceInit
*
* Mixer sources and destinations may be written and read by the MCU (via the
* provided APIs: \ref Cy_Mixer_Src_FifoWriteData, \ref Cy_Mixer_Dst_FifoReadData)
* or by DMA. If using DMA, the DMA channel should be previously configured.
* Triggers generated by the Mixer can be used to initiate DMA transfers to and
* from the mixer source and destination FIFOs.
*
* \section group_mixer_more_information More Information.
* See the Mixer chapter of the device technical reference manual (TRM).
*
* \section group_mixer_changelog Changelog
*
* <table class="doxtable">
*   <tr><th>Version</th><th>Changes</th><th>Reason for Change</th></tr>
*   <tr>
*     <td>1.0</td>
*     <td>The initial version.</td>
*     <td></td>
*   </tr>
* </table>
*
* \defgroup group_mixer_macros Macros
* \defgroup group_mixer_functions Functions
* \defgroup group_mixer_data_structures Data Structures
* \defgroup group_mixer_enums Enumerated Types
*/

#if !defined(__CY_MIXER_H__)
#define __CY_MIXER_H__

#include "cy_device_headers.h"
#include "cy_syslib.h"
#include <stdbool.h>

#if defined (CY_IP_MXMIXER)

#if defined(__cplusplus)
extern "C" {
#endif /* __cplusplus */

/**
* \addtogroup group_mixer_macros
* \{
*/

/** Driver major version */
#define CY_MIXER_DRV_VERSION_MAJOR   1
/** Driver minor version */
#define CY_MIXER_DRV_VERSION_MINOR   0
/** The Mixer driver identifier */
#define CY_MIXER_ID                (CY_PDL_DRV_ID(0x25U))

/** Mixer gain code: mute */
#define CY_MIXER_GAIN_CODE_MUTE (0U)
/** Mixer gain code: no gain */
#define CY_MIXER_GAIN_CODE_NONE (115U)
/** Mixer gain code: maximum gain */
#define CY_MIXER_GAIN_CODE_MAX  (127U)

/** \} group_mixer_macros */

/**
* \addtogroup group_mixer_enums
* \{
*/

/** Mixer Word Size */
typedef enum
{
    CY_MIXER_TX_WD_SIZE_16BITS      = 4U,    /**< MIXER transmitter PCM Word Size - always uses 16-bit PCM words. */
} cy_en_mixer_tx_wd_size_t;

/** Mixer TX Format */
typedef enum
{
    CY_MIXER_TX_FMT_LEFT_DELAYED    = 0U,    /**< MIXER transmitter Format left delayed */
    CY_MIXER_TX_FMT_LEFT            = 1U,    /**< MIXER transmitter Format left */
    CY_MIXER_TX_FMT_RIGHT_DELAYED   = 2U,    /**< MIXER transmitter Format right delayed */
    CY_MIXER_TX_FMT_RIGHT           = 3U,    /**< MIXER transmitter Format right */
} cy_en_mixer_tx_fmt_t;

/** Mixer TX Mode */
typedef enum
{
    CY_MIXER_TX_MODE_SLAVE          = 0U,    /**< MIXER transmitter slave mode */
    CY_MIXER_TX_MODE_MASTER         = 1U,    /**< MIXER transmitter master mode */
} cy_en_mixer_tx_mode_t;

/** Mixer TX Interface Clock Selection */
typedef enum
{
    CY_MIXER_TX_CLK_SEL_SRSS        = 0U,    /**< MIXER transmitter Clock Select SRSS Internal */
    CY_MIXER_TX_CLK_SEL_MASTER_IFC  = 1U,    /**< MIXER transmitter Clock Select from Master Interface */
} cy_en_mixer_tx_clk_sel_t;

/** Mixer Channel */
typedef enum
{
    CY_MIXER_CHANNEL0               = 0U,    /**< MIXER Channel 0 */
    CY_MIXER_CHANNEL1               = 1U,    /**< MIXER Channel 1 */
} cy_en_mixer_channel_t;

/** Mixer Tx Interrupt Sources */
typedef enum
{
    CY_MIXER_TX_FIFO_UNDERFLOW      = 0U,    /**< MIXER Fifo underflow interrupt */
    CY_MIXER_TX_IFC_UNDERFLOW       = 1U,    /**< MIXER Interface underflow interrupt */
} cy_stc_mixer_tx_int_src_t;

/** Mixer Source Interrupt Sources */
typedef enum
{
    CY_MIXER_SRC_FIFO_TRIGGER       = 0U,    /**< MIXER source Fifo trigger interrupt */
    CY_MIXER_SRC_FIFO_OVERFLOW      = 1U,    /**< MIXER source Fifo overflow interrupt */
    CY_MIXER_SRC_FADE_OUT           = 2U,    /**< MIXER source fade out interrupt */
} cy_en_mixer_src_interrupt_t;

/** Mixer Destination Interrupt Sources */
typedef enum
{
    CY_MIXER_DST_FIFO_TRIGGER       = 0U,    /**< MIXER destination Fifo trigger interrupt */
    CY_MIXER_DST_FIFO_UNDERFLOW     = 1U,    /**< MIXER destination Fifo underflow interrupt */
    CY_MIXER_DST_FADE_OUT           = 2U,    /**< MIXER destination fade out interrupt */
} cy_en_mixer_dst_interrupt_t;

/** Mixer Sample Frequency Upscale Ratio */
typedef enum
{
    CY_MIXER_SRC_FREQ_DOWNSAMPLE_BY_2   = 0U,    /**< MIXER source frequency down sample by 2 */
    CY_MIXER_SRC_FREQ_NO_RESAMPLE       = 1U,    /**< MIXER source frequency no resampling, same */
    CY_MIXER_SRC_FREQ_UPSAMPLE_BY_2     = 2U,    /**< MIXER source frequency up sampling by 2 (0.5) */
    CY_MIXER_SRC_FREQ_UPSAMPLE_BY_3     = 3U,    /**< MIXER source frequency up sampling by 3 */
    CY_MIXER_SRC_FREQ_UPSAMPLE_BY_4     = 4U,    /**< MIXER source frequency up sampling by 4 */
    CY_MIXER_SRC_FREQ_UPSAMPLE_BY_6     = 5U,    /**< MIXER source frequency up sampling by 6 */
    CY_MIXER_SRC_FREQ_UPSAMPLE_BY_8     = 6U,    /**< MIXER source frequency up sampling by 8 */
    CY_MIXER_SRC_FREQ_UPSAMPLE_BY_12    = 7U,    /**< MIXER source frequency up sampling by 12 */
} cy_en_mixer_src_fs_ratio_t;

/** Mixer source channel data select */
/**
* \note
* This enum specifies selection of the channel's 16-bit PCM data from the source FIFO data[31:0].
**/
typedef enum
{
    CY_MIXER_SRC_DATA_LOW   = 0U, /**< MIXER source data from data[15:0] (default setting) */
    CY_MIXER_SRC_DATA_HIGH  = 1U, /**< MIXER source data from data[31:16] */
    CY_MIXER_SRC_CONSTANT_0 = 2U, /**< MIXER source data is a constant PCM data value of "0", no source FIFO */
} cy_en_mixer_src_data_t;

/** Mixer Fade Code Select */
typedef enum
{
    CY_MIXER_CODE_MUTE = CY_MIXER_GAIN_CODE_MUTE, /**< MIXER fade gain code 0 */
    CY_MIXER_CODE_SAME = CY_MIXER_GAIN_CODE_NONE, /**< MIXER fade gain code 115 */
} cy_en_mixer_fade_code_t;

/** Mixer status definitions. */
typedef enum
{
    CY_MIXER_SUCCESS   = 0x00UL,                                    /**< Successful. */
    CY_MIXER_BAD_PARAM = CY_MIXER_ID | CY_PDL_STATUS_ERROR | 0x01UL /**< One or more invalid parameters. */
} cy_en_mixer_status_t;

/** \} group_mixer_enums */

/**
* \addtogroup group_mixer_data_structures
* \{
*/

/** Mixer Source initialization configuration. */
typedef struct
{
    cy_en_mixer_src_fs_ratio_t fsRatio;  /**< Sample frequency upscale ratio */
    cy_en_mixer_src_data_t     ch0sel;   /**< Channel 0 bit allocation */
    cy_en_mixer_src_data_t     ch1sel;   /**< Channel 0 bit allocation */
    cy_en_mixer_fade_code_t    fadeCode; /**< Initial fade state */
    uint8_t                    gainCode; /**< Gain code in the range [0, 127]. */
    uint8_t                    trgLevel; /**< Trigger level */
} cy_stc_mixer_src_config_t;

/** Mixer Destination initialization configuration. */
typedef struct
{
    cy_en_mixer_fade_code_t fadeCode; /**< Initial fade state */
    uint8_t                 gainCode; /**< Gain code in the range [0, 127]. */
    uint8_t                 trgLevel; /**< Trigger level */
} cy_stc_mixer_dst_config_t;

/** Mixer Transmit initialization configuration. */
typedef struct
{
    cy_en_mixer_tx_wd_size_t    wordSize;    /**< PCM Word Size, only 16-bits */
    cy_en_mixer_tx_fmt_t        txFormat;    /**< I2S Format */
    cy_en_mixer_tx_mode_t       txMode;      /**< Master Mode */
    uint8_t                     clkDiv;      /**< I2S Interface clock divider [1...255] */
    cy_en_mixer_tx_clk_sel_t    clkSel;      /**< Clock Select from either SRSS (internal) or Master Ifc */
    bool                        clkPol;      /**< Clock polarity, as is or inverted */
    bool                        wSelPol;     /**< Word select polarity, as is or inverted */
    bool                        chl0En;      /**< Channel 0 enable */
    bool                        chl1En;      /**< Channel 1 enable */
    uint8_t                     chlSize;     /**< Channel size, [1..32] */
} cy_stc_mixer_tx_config_t;

/** \} group_mixer_data_structures */

/**
* \addtogroup group_mixer_functions
* \{
*/
/*******************************************************************************/
/*                      Global initialization functions                        */
/*******************************************************************************/
cy_en_mixer_status_t Cy_Mixer_SourceInit(volatile MIXER_SRC_STRUCT_Type * base, cy_stc_mixer_src_config_t const * config);
void Cy_Mixer_SourceDeInit(volatile MIXER_SRC_STRUCT_Type * base);
cy_en_mixer_status_t Cy_Mixer_DestinationInit(volatile MIXER_DST_STRUCT_Type * base, cy_stc_mixer_dst_config_t const * config);
void Cy_Mixer_DestinationDeInit(volatile MIXER_DST_STRUCT_Type * base);

#if (defined(MIXER0_TX_PRESENT) && (MIXER0_TX_PRESENT == 1)) || (defined(MIXER1_TX_PRESENT) && (MIXER1_TX_PRESENT == 1))
cy_en_mixer_status_t Cy_Mixer_TransmitInit(volatile MIXER_TX_STRUCT_Type * base, cy_stc_mixer_tx_config_t const * config);
void Cy_Mixer_TransmitDeInit(volatile MIXER_TX_STRUCT_Type * base);
#endif

void Cy_Mixer_SourceStartFadeIn(volatile MIXER_SRC_STRUCT_Type * base, uint16_t pace);
bool Cy_Mixer_SourceHasFadeInCompleted(volatile MIXER_SRC_STRUCT_Type * base);
void Cy_Mixer_SourceStartFadeOut(volatile MIXER_SRC_STRUCT_Type * base, uint16_t pace, bool deact);
bool Cy_Mixer_SourceHasFadeOutCompleted(volatile MIXER_SRC_STRUCT_Type * base);

void Cy_Mixer_DestinationStartFadeIn(volatile MIXER_DST_STRUCT_Type * base, uint16_t pace);
bool Cy_Mixer_DestinationHasFadeInCompleted(volatile MIXER_DST_STRUCT_Type * base);
void Cy_Mixer_DestinationStartFadeOut(volatile MIXER_DST_STRUCT_Type * base, uint16_t pace, bool deact);
bool Cy_Mixer_DestinationHasFadeOutCompleted(volatile MIXER_DST_STRUCT_Type * base);

/*******************************************************************************/
/*                      Mixer Source Control and Status                        */
/*******************************************************************************/
__STATIC_INLINE void Cy_Mixer_Src_SampleFreqRatio(volatile MIXER_SRC_STRUCT_Type * base, cy_en_mixer_src_fs_ratio_t fsRatio);
__STATIC_INLINE void Cy_Mixer_Src_ChannelSelect(volatile MIXER_SRC_STRUCT_Type * base, cy_en_mixer_channel_t channel, cy_en_mixer_src_data_t data);
__STATIC_INLINE void Cy_Mixer_Src_Enable(volatile MIXER_SRC_STRUCT_Type * base);
__STATIC_INLINE void Cy_Mixer_Src_Disable(volatile MIXER_SRC_STRUCT_Type * base);

__STATIC_INLINE uint8_t Cy_Mixer_Src_GetCurrentPhase(volatile MIXER_SRC_STRUCT_Type * base);

__STATIC_INLINE void Cy_Mixer_Src_FadeControl(volatile MIXER_SRC_STRUCT_Type * base, cy_en_mixer_fade_code_t fadeCode);

__STATIC_INLINE uint16_t Cy_Mixer_Src_GetCurrentPace(volatile MIXER_SRC_STRUCT_Type * base);

__STATIC_INLINE void Cy_Mixer_Src_FadeInEnable(volatile MIXER_SRC_STRUCT_Type * base);
__STATIC_INLINE void Cy_Mixer_Src_FadeInDisable(volatile MIXER_SRC_STRUCT_Type * base);
__STATIC_INLINE void Cy_Mixer_Src_FadeOutEnable(volatile MIXER_SRC_STRUCT_Type * base);
__STATIC_INLINE void Cy_Mixer_Src_FadeOutDisable(volatile MIXER_SRC_STRUCT_Type * base);
__STATIC_INLINE void Cy_Mixer_Src_AutoFadeActivate(volatile MIXER_SRC_STRUCT_Type * base);
__STATIC_INLINE void Cy_Mixer_Src_AutoFadeDeactivate(volatile MIXER_SRC_STRUCT_Type * base);
__STATIC_INLINE void Cy_Mixer_Src_FadePaceSelect(volatile MIXER_SRC_STRUCT_Type * base, uint16_t pace);

__STATIC_INLINE void Cy_Mixer_Src_GainCodeSelect(volatile MIXER_SRC_STRUCT_Type * base, uint8_t code);

__STATIC_INLINE void Cy_Mixer_Src_FifoTriggerLevel(volatile MIXER_SRC_STRUCT_Type * base, uint8_t level);
__STATIC_INLINE void Cy_Mixer_Src_Mute(volatile MIXER_SRC_STRUCT_Type * base);
__STATIC_INLINE void Cy_Mixer_Src_Unmute(volatile MIXER_SRC_STRUCT_Type * base);
__STATIC_INLINE void Cy_Mixer_Src_Activate(volatile MIXER_SRC_STRUCT_Type * base);
__STATIC_INLINE void Cy_Mixer_Src_Deactivate(volatile MIXER_SRC_STRUCT_Type * base);

__STATIC_INLINE uint8_t Cy_Mixer_Src_GetUsedFifoEntries(volatile MIXER_SRC_STRUCT_Type * base);
__STATIC_INLINE uint8_t Cy_Mixer_Src_GetFifoReadPtr(volatile MIXER_SRC_STRUCT_Type * base);
__STATIC_INLINE uint8_t Cy_Mixer_Src_GetFifoWritePtr(volatile MIXER_SRC_STRUCT_Type * base);

__STATIC_INLINE void Cy_Mixer_Src_FifoWriteData(volatile MIXER_SRC_STRUCT_Type * base, uint32_t data);

__STATIC_INLINE void Cy_Mixer_Src_ClearInterrupt(volatile MIXER_SRC_STRUCT_Type * base, cy_en_mixer_src_interrupt_t intSrc);
__STATIC_INLINE void Cy_Mixer_Src_SetInterrupt(volatile MIXER_SRC_STRUCT_Type * base, cy_en_mixer_src_interrupt_t intSrc);
__STATIC_INLINE void Cy_Mixer_Src_ClearInterruptMask(volatile MIXER_SRC_STRUCT_Type * base, cy_en_mixer_src_interrupt_t intSrc);
__STATIC_INLINE void Cy_Mixer_Src_SetInterruptMask(volatile MIXER_SRC_STRUCT_Type * base, cy_en_mixer_src_interrupt_t intSrc);
__STATIC_INLINE bool Cy_Mixer_Src_IsInterruptActive(volatile MIXER_SRC_STRUCT_Type * base, cy_en_mixer_src_interrupt_t intSrc);

/*******************************************************************************/
/*                   Mixer Destination Control and Status                      */
/*******************************************************************************/
__STATIC_INLINE void Cy_Mixer_Dst_Enable(volatile MIXER_DST_STRUCT_Type * base);
__STATIC_INLINE void Cy_Mixer_Dst_Disable(volatile MIXER_DST_STRUCT_Type * base);

__STATIC_INLINE void Cy_Mixer_Dst_FadeControl(volatile MIXER_DST_STRUCT_Type * base, cy_en_mixer_fade_code_t fadeCode);

__STATIC_INLINE uint16_t Cy_Mixer_Dst_GetCurrentPace(volatile MIXER_DST_STRUCT_Type * base);

__STATIC_INLINE void Cy_Mixer_Dst_FadeInEnable(volatile MIXER_DST_STRUCT_Type * base);
__STATIC_INLINE void Cy_Mixer_Dst_FadeInDisable(volatile MIXER_DST_STRUCT_Type * base);
__STATIC_INLINE void Cy_Mixer_Dst_FadeOutEnable(volatile MIXER_DST_STRUCT_Type * base);
__STATIC_INLINE void Cy_Mixer_Dst_FadeOutDisable(volatile MIXER_DST_STRUCT_Type * base);
__STATIC_INLINE void Cy_Mixer_Dst_AutoFadeActivate(volatile MIXER_DST_STRUCT_Type * base);
__STATIC_INLINE void Cy_Mixer_Dst_AutoFadeDeactivate(volatile MIXER_DST_STRUCT_Type * base);
__STATIC_INLINE void Cy_Mixer_Dst_FadePaceSelect(volatile MIXER_DST_STRUCT_Type * base, uint16_t pace);

__STATIC_INLINE void Cy_Mixer_Dst_GainCodeSelect(volatile MIXER_DST_STRUCT_Type * base, uint8_t code);

__STATIC_INLINE void Cy_Mixer_Dst_FifoTriggerLevel(volatile MIXER_DST_STRUCT_Type * base, uint8_t level);
__STATIC_INLINE void Cy_Mixer_Dst_Mute(volatile MIXER_DST_STRUCT_Type * base);
__STATIC_INLINE void Cy_Mixer_Dst_Unmute(volatile MIXER_DST_STRUCT_Type * base);
__STATIC_INLINE void Cy_Mixer_Dst_Activate(volatile MIXER_DST_STRUCT_Type * base);
__STATIC_INLINE void Cy_Mixer_Dst_Deactivate(volatile MIXER_DST_STRUCT_Type * base);

__STATIC_INLINE uint8_t Cy_Mixer_Dst_GetUsedFifoEntries(volatile MIXER_DST_STRUCT_Type * base);
__STATIC_INLINE uint8_t Cy_Mixer_Dst_GetFifoReadPtr(volatile MIXER_DST_STRUCT_Type * base);
__STATIC_INLINE uint8_t Cy_Mixer_Dst_GetFifoWritePtr(volatile MIXER_DST_STRUCT_Type * base);

__STATIC_INLINE uint32_t Cy_Mixer_Dst_FifoReadData(volatile MIXER_DST_STRUCT_Type * base);

__STATIC_INLINE void Cy_Mixer_Dst_ClearInterrupt(volatile MIXER_DST_STRUCT_Type * base, cy_en_mixer_dst_interrupt_t intSrc);
__STATIC_INLINE void Cy_Mixer_Dst_SetInterrupt(volatile MIXER_DST_STRUCT_Type * base, cy_en_mixer_dst_interrupt_t intSrc);
__STATIC_INLINE void Cy_Mixer_Dst_ClearInterruptMask(volatile MIXER_DST_STRUCT_Type * base, cy_en_mixer_dst_interrupt_t intSrc);
__STATIC_INLINE void Cy_Mixer_Dst_SetInterruptMask(volatile MIXER_DST_STRUCT_Type * base, cy_en_mixer_dst_interrupt_t intSrc);
__STATIC_INLINE bool Cy_Mixer_Dst_IsInterruptActive(volatile MIXER_DST_STRUCT_Type * base, cy_en_mixer_dst_interrupt_t intSrc);

/*******************************************************************************/
/*                       Mixer Tx Control and Status                           */
/*******************************************************************************/
#if (defined(MIXER0_TX_PRESENT) && (MIXER0_TX_PRESENT == 1)) || (defined(MIXER1_TX_PRESENT) && (MIXER1_TX_PRESENT == 1))

__STATIC_INLINE void Cy_Mixer_Tx_Enable(volatile MIXER_TX_STRUCT_Type * base);
__STATIC_INLINE void Cy_Mixer_Tx_Disable(volatile MIXER_TX_STRUCT_Type * base);
__STATIC_INLINE void Cy_Mixer_Tx_WordSize(volatile MIXER_TX_STRUCT_Type * base, cy_en_mixer_tx_wd_size_t wdSize);
__STATIC_INLINE void Cy_Mixer_Tx_Format(volatile MIXER_TX_STRUCT_Type * base, cy_en_mixer_tx_fmt_t format);
__STATIC_INLINE void Cy_Mixer_Tx_SelectMode(volatile MIXER_TX_STRUCT_Type * base, cy_en_mixer_tx_mode_t mode);

__STATIC_INLINE void Cy_Mixer_Tx_ClockDivider(volatile MIXER_TX_STRUCT_Type * base, uint8_t clkDiv);
__STATIC_INLINE void Cy_Mixer_Tx_ClockSelect(volatile MIXER_TX_STRUCT_Type * base, cy_en_mixer_tx_clk_sel_t clkSel);
__STATIC_INLINE void Cy_Mixer_Tx_ClockPolarity(volatile MIXER_TX_STRUCT_Type * base, bool polarity);
__STATIC_INLINE void Cy_Mixer_Tx_WordSelectPolarity(volatile MIXER_TX_STRUCT_Type * base, bool polarity);
__STATIC_INLINE void Cy_Mixer_Tx_ChannelEnable(volatile MIXER_TX_STRUCT_Type * base, cy_en_mixer_channel_t channel);
__STATIC_INLINE void Cy_Mixer_Tx_ChannelDisable(volatile MIXER_TX_STRUCT_Type * base, cy_en_mixer_channel_t channel);
__STATIC_INLINE void Cy_Mixer_Tx_ChannelSize(volatile MIXER_TX_STRUCT_Type * base, uint8_t chSize);

__STATIC_INLINE void Cy_Mixer_Tx_Mute(volatile MIXER_TX_STRUCT_Type * base);
__STATIC_INLINE void Cy_Mixer_Tx_Unmute(volatile MIXER_TX_STRUCT_Type * base);
__STATIC_INLINE void Cy_Mixer_Tx_ActivateTransmitter(volatile MIXER_TX_STRUCT_Type * base, bool state);
__STATIC_INLINE void Cy_Mixer_Tx_Replay(volatile MIXER_TX_STRUCT_Type * base, bool state);

__STATIC_INLINE void Cy_Mixer_Tx_ClearInterrupt(volatile MIXER_TX_STRUCT_Type * base, cy_stc_mixer_tx_int_src_t intSrc);
__STATIC_INLINE void Cy_Mixer_Tx_SetInterrupt(volatile MIXER_TX_STRUCT_Type * base, cy_stc_mixer_tx_int_src_t intSrc);
__STATIC_INLINE void Cy_Mixer_Tx_ClearInterruptMask(volatile MIXER_TX_STRUCT_Type * base, cy_stc_mixer_tx_int_src_t intSrc);
__STATIC_INLINE void Cy_Mixer_Tx_SetInterruptMask(volatile MIXER_TX_STRUCT_Type * base, cy_stc_mixer_tx_int_src_t intSrc);
__STATIC_INLINE bool Cy_Mixer_Tx_IsInterruptActive(volatile MIXER_TX_STRUCT_Type * base, cy_stc_mixer_tx_int_src_t intSrc);

#endif /* (defined(MIXER0_TX_PRESENT) && (MIXER0_TX_PRESENT == 1)) || (defined(MIXER1_TX_PRESENT) && (MIXER1_TX_PRESENT == 1)) */

/*******************************************************************************
* Function Name: Cy_Mixer_Src_SampleFreqRatio
****************************************************************************//**
*
* Set the source sample frequency upscale ratio
*
* \param base pointer to the Mixer SRC Struct instance
* \param fsRatio \ref cy_en_mixer_src_fs_ratio_t
*
*******************************************************************************/
__STATIC_INLINE void Cy_Mixer_Src_SampleFreqRatio(volatile MIXER_SRC_STRUCT_Type * base, cy_en_mixer_src_fs_ratio_t fsRatio)
{
    CY_REG32_CLR_SET(MIXER_SRC_STRUCT_SRC_CTL(base), MIXER_MIXER_SRC_STRUCT_SRC_CTL_FS_RATIO, fsRatio);
}

/*******************************************************************************
* Function Name: Cy_Mixer_Src_ChannelSelect
****************************************************************************//**
*
* Channel selection, specifies selection of the channel's 16-bit PCM data from
* source FIFO data[31:0].
*
* \param base pointer to the Mixer SRC Struct instance
* \param channel \ref cy_en_mixer_channel_t
* \param data \ref cy_en_mixer_src_data_t
*
*******************************************************************************/
__STATIC_INLINE void Cy_Mixer_Src_ChannelSelect(volatile MIXER_SRC_STRUCT_Type * base, cy_en_mixer_channel_t channel, cy_en_mixer_src_data_t data)
{
    switch (channel)
    {
    case CY_MIXER_CHANNEL0:
        CY_REG32_CLR_SET(MIXER_SRC_STRUCT_SRC_CTL(base), MIXER_MIXER_SRC_STRUCT_SRC_CTL_CH0_SEL, data);
        break;
    case CY_MIXER_CHANNEL1:
        CY_REG32_CLR_SET(MIXER_SRC_STRUCT_SRC_CTL(base), MIXER_MIXER_SRC_STRUCT_SRC_CTL_CH1_SEL, data);
        break;
    default:
        /* Invalid channel */
        CY_ASSERT_L3(false);
        break;
    }
}

/*******************************************************************************
* Function Name: Cy_Mixer_Src_Enable
****************************************************************************//**
*
* Mixer source enable
*
* \param base pointer to the Mixer SRC Struct instance
*
* \funcusage
* \snippet mixer/snippet/main.c snippet_Cy_Mixer_SourceInit
*
*******************************************************************************/
__STATIC_INLINE void Cy_Mixer_Src_Enable(volatile MIXER_SRC_STRUCT_Type * base)
{
    MIXER_SRC_STRUCT_SRC_CTL(base) |= MIXER_MIXER_SRC_STRUCT_SRC_CTL_ENABLED_Msk;
}

/*******************************************************************************
* Function Name: Cy_Mixer_Src_Disable
****************************************************************************//**
*
* Mixer source disable
*
* \param base pointer to the Mixer SRC Struct instance
*
* \funcusage
* \snippet mixer/snippet/main.c snippet_Cy_Mixer_Src_Disable
*
*******************************************************************************/
__STATIC_INLINE void Cy_Mixer_Src_Disable(volatile MIXER_SRC_STRUCT_Type * base)
{
    MIXER_SRC_STRUCT_SRC_CTL(base) &= ~MIXER_MIXER_SRC_STRUCT_SRC_CTL_ENABLED_Msk;
}

/*******************************************************************************
* Function Name: Cy_Mixer_Src_GetCurrentPhase
****************************************************************************//**
*
* Get the current FIR phase value. An upscale ratio of "n" uses a n polyphase
* FIR filter. The phases are numbered [0, n-1].
*
* \param base pointer to the Mixer SRC Struct instance
*
* \return The current FIR phase value.
*
*******************************************************************************/
__STATIC_INLINE uint8_t Cy_Mixer_Src_GetCurrentPhase(volatile MIXER_SRC_STRUCT_Type * base)
{
    return (uint8_t)(_FLD2VAL(MIXER_MIXER_SRC_STRUCT_SRC_STATUS_PHASE, MIXER_SRC_STRUCT_SRC_STATUS(base)));
}

/*******************************************************************************
* Function Name: Cy_Mixer_Src_FadeControl
****************************************************************************//**
*
* Set the source fade control (Gain code in the range [0, 115])
*
* \param base pointer to the Mixer SRC Struct instance
* \param fadeCode \ref cy_en_mixer_fade_code_t
*
*******************************************************************************/
__STATIC_INLINE void Cy_Mixer_Src_FadeControl(volatile MIXER_SRC_STRUCT_Type * base, cy_en_mixer_fade_code_t fadeCode)
{
    MIXER_SRC_STRUCT_SRC_FADE_CTL(base) = _VAL2FLD(MIXER_MIXER_SRC_STRUCT_SRC_FADE_CTL_CODE, fadeCode);
}

/*******************************************************************************
* Function Name: Cy_Mixer_Src_GetCurrentPace
****************************************************************************//**
*
* Get the current source fading pace counter value. SRC_FADE_CTL.PACE value of "n"
* reuses a specific fade value "n+1" times.
*
* \param base pointer to the Mixer SRC Struct instance
*
* \return The current fading pace counter value
*
*******************************************************************************/
__STATIC_INLINE uint16_t Cy_Mixer_Src_GetCurrentPace(volatile MIXER_SRC_STRUCT_Type * base)
{
    return (uint8_t)(_FLD2VAL(MIXER_MIXER_SRC_STRUCT_SRC_FADE_STATUS_PACE, MIXER_SRC_STRUCT_SRC_FADE_STATUS(base)));
}

/*******************************************************************************
* Function Name: Cy_Mixer_Src_FadeInEnable
****************************************************************************//**
*
* Mixer source fade in enable (SW sets this field to '1' to start "fade in"
* functionality. HW clears this field to '0' to indicate that "fade in" has
* completed)
*
* FADE_IN and FADE_OUT should be used mutually exclusively. However, if
* "fade in" is desired while "fading out", SW can set FADE_IN to '1' and clear
* FADE_OUT to '0'. "Fade in" will commence from the current CODE value.
* Similarly,  if "fade out" is desired while "fading in", SW can set FADE_OUT
* to '1' and clear FADE_IN to '0'. "Fade out" will commence from the current
* CODE value.
*
* \param base pointer to the Mixer SRC Struct instance
*
*******************************************************************************/
__STATIC_INLINE void Cy_Mixer_Src_FadeInEnable(volatile MIXER_SRC_STRUCT_Type * base)
{
    MIXER_SRC_STRUCT_SRC_FADE_CMD(base) |= MIXER_MIXER_SRC_STRUCT_SRC_FADE_CMD_FADE_IN_Msk;
}

/*******************************************************************************
* Function Name: Cy_Mixer_Src_FadeInDisable
****************************************************************************//**
*
* Mixer source fade in disable
*
* \param base pointer to the Mixer SRC Struct instance
*
*******************************************************************************/
__STATIC_INLINE void Cy_Mixer_Src_FadeInDisable(volatile MIXER_SRC_STRUCT_Type * base)
{
    MIXER_SRC_STRUCT_SRC_FADE_CMD(base) &= ~MIXER_MIXER_SRC_STRUCT_SRC_FADE_CMD_FADE_IN_Msk;
}

/*******************************************************************************
* Function Name: Cy_Mixer_Src_FadeOutEnable
****************************************************************************//**
*
* Mixer source fade out enable
*
* \param base pointer to the Mixer SRC Struct instance
*
*******************************************************************************/
__STATIC_INLINE void Cy_Mixer_Src_FadeOutEnable(volatile MIXER_SRC_STRUCT_Type * base)
{
    MIXER_SRC_STRUCT_SRC_FADE_CMD(base) |= MIXER_MIXER_SRC_STRUCT_SRC_FADE_CMD_FADE_OUT_Msk;
}

/*******************************************************************************
* Function Name: Cy_Mixer_Src_FadeOutDisable
****************************************************************************//**
*
* Mixer source fade out disable
*
* \param base pointer to the Mixer SRC Struct instance
*
*******************************************************************************/
__STATIC_INLINE void Cy_Mixer_Src_FadeOutDisable(volatile MIXER_SRC_STRUCT_Type * base)
{
    MIXER_SRC_STRUCT_SRC_FADE_CMD(base) &= ~MIXER_MIXER_SRC_STRUCT_SRC_FADE_CMD_FADE_OUT_Msk;
}

/*******************************************************************************
* Function Name: Cy_Mixer_Src_AutoFadeActivate
****************************************************************************//**
*
* Configures the mixer source to NOT deactivate when "fade out" completes
*
* \param base pointer to the Mixer SRC Struct instance
*
*******************************************************************************/
__STATIC_INLINE void Cy_Mixer_Src_AutoFadeActivate(volatile MIXER_SRC_STRUCT_Type * base)
{
    MIXER_SRC_STRUCT_SRC_FADE_CMD(base) &= ~MIXER_MIXER_SRC_STRUCT_SRC_FADE_CMD_AUTO_DEACTIVATE_Msk;
}

/*******************************************************************************
* Function Name: Cy_Mixer_Src_AutoFadeDeactivate
****************************************************************************//**
*
* Configures the mixer source to automatically deactivate when "fade out"
* completes
*
* \param base pointer to the Mixer SRC Struct instance
*
*******************************************************************************/
__STATIC_INLINE void Cy_Mixer_Src_AutoFadeDeactivate(volatile MIXER_SRC_STRUCT_Type * base)
{
    MIXER_SRC_STRUCT_SRC_FADE_CMD(base) |= MIXER_MIXER_SRC_STRUCT_SRC_FADE_CMD_AUTO_DEACTIVATE_Msk;
}

/*******************************************************************************
* Function Name: Cy_Mixer_Src_FadePaceSelect
****************************************************************************//**
*
* Specifies the pace/speed of source "fade in" and "fade out"
*
* \param base pointer to the Mixer SRC Struct instance
* \param pace (10-bit value)
*          "0": The same CODE value is used (0+1) times,
*          "1": The same CODE value is used (1+1) times.
*          ...
*          "1023": The same CODE value is used (1023+1) times.
*           A fade in from "mute" to 0 dB takes 1024*116 = 118,784 PCM samples. At a PCM sample frequency
*           Fs of 48 kHz, this translates into 118,784/48,000 = 2.474 seconds.
*
*******************************************************************************/
__STATIC_INLINE void Cy_Mixer_Src_FadePaceSelect(volatile MIXER_SRC_STRUCT_Type * base, uint16_t pace)
{
    CY_REG32_CLR_SET(MIXER_SRC_STRUCT_SRC_FADE_CMD(base), MIXER_MIXER_SRC_STRUCT_SRC_FADE_CMD_PACE, pace);
}

/*******************************************************************************
* Function Name: Cy_Mixer_Src_GainCodeSelect
****************************************************************************//**
*
* Set the source gain code in the range [0, 127].
* Each gain code increment represents 1 dB.
* Gain code value "0" represents digital mute.
* Gain code "127" represents a maximum amplification of 12 dB.
*
* \param base pointer to the Mixer SRC Struct instance
* \param code (7-bit value)
*            "0": digital mute. Multiplier value is "0" and "shift" is "26".
*            "1": -114 dB. Multiplier value is "134" and "shift" is "26".
*            "2": -113 dB. Multiplier value is "150" and "shift" is "26".
*            "3": -112 dB. Multiplier value is "169" and "shift" is "26".
*            ...
*            "115": 0 dB. Multiplier value is "4096" and "shift" is "12". Note that (4096 * x) >> 12 = x; i.e. the PCM value is unaffected.
*            ...
*            "121": 6 dB. Multiplier value is "8173" and "shift" is "12".
*            ...
*            "127": 12 dB. Multiplier value is "8153" and "shift" is "11".
*
*******************************************************************************/
__STATIC_INLINE void Cy_Mixer_Src_GainCodeSelect(volatile MIXER_SRC_STRUCT_Type * base, uint8_t code)
{
    MIXER_SRC_STRUCT_SRC_GAIN_CTL(base) = _VAL2FLD(MIXER_MIXER_SRC_STRUCT_SRC_GAIN_CTL_CODE, code);
}

/*******************************************************************************
* Function Name: Cy_Mixer_Src_FifoTriggerLevel
****************************************************************************//**
*
* Set the source FIFO trigger level.
* When the source FIFO has fewer entries than the number of this field,
* a transmitter trigger event is generated.
*
* \param base pointer to the Mixer SRC Struct instance
* \param level (7-bit value) (INTR_SRC.FIFO_TRIGGER = (# FIFO entries < TRIGGER_LEVEL))
*
*******************************************************************************/
__STATIC_INLINE void Cy_Mixer_Src_FifoTriggerLevel(volatile MIXER_SRC_STRUCT_Type * base, uint8_t level)
{
    CY_REG32_CLR_SET(MIXER_SRC_STRUCT_SRC_FIFO_CTL(base), MIXER_MIXER_SRC_STRUCT_SRC_FIFO_CTL_TRIGGER_LEVEL, level);
}

/*******************************************************************************
* Function Name: Cy_Mixer_Src_Mute
****************************************************************************//**
*
* Mute the mixer source
*
* \param base pointer to the Mixer SRC Struct instance
*
* \funcusage
* \snippet mixer/snippet/main.c snippet_Cy_Mixer_Src_Mute
*
*******************************************************************************/
__STATIC_INLINE void Cy_Mixer_Src_Mute(volatile MIXER_SRC_STRUCT_Type * base)
{
    MIXER_SRC_STRUCT_SRC_FIFO_CTL(base) |= MIXER_MIXER_SRC_STRUCT_SRC_FIFO_CTL_MUTE_Msk;
}

/*******************************************************************************
* Function Name: Cy_Mixer_Src_Unmute
****************************************************************************//**
*
* Unmute the mixer source
*
* \param base pointer to the Mixer SRC Struct instance
*
* \funcusage
* \snippet mixer/snippet/main.c snippet_Cy_Mixer_Src_Unmute
*
*******************************************************************************/
__STATIC_INLINE void Cy_Mixer_Src_Unmute(volatile MIXER_SRC_STRUCT_Type * base)
{
    MIXER_SRC_STRUCT_SRC_FIFO_CTL(base) &= ~MIXER_MIXER_SRC_STRUCT_SRC_FIFO_CTL_MUTE_Msk;
}

/*******************************************************************************
* Function Name: Cy_Mixer_Src_Activate
****************************************************************************//**
*
* Activate the mixer source
*
* \param base pointer to the Mixer SRC Struct instance
*
* \funcusage
* \snippet mixer/snippet/main.c snippet_Cy_Mixer_SourceInit
*
*******************************************************************************/
__STATIC_INLINE void Cy_Mixer_Src_Activate(volatile MIXER_SRC_STRUCT_Type * base)
{
    MIXER_SRC_STRUCT_SRC_FIFO_CTL(base) |= MIXER_MIXER_SRC_STRUCT_SRC_FIFO_CTL_ACTIVE_Msk;
}

/*******************************************************************************
* Function Name: Cy_Mixer_Src_Deactivate
****************************************************************************//**
*
* Deactivate the mixer source
*
* \param base pointer to the Mixer SRC Struct instance
*
* \funcusage
* \snippet mixer/snippet/main.c snippet_Cy_Mixer_Src_Disable
*
*******************************************************************************/
__STATIC_INLINE void Cy_Mixer_Src_Deactivate(volatile MIXER_SRC_STRUCT_Type * base)
{
    MIXER_SRC_STRUCT_SRC_FIFO_CTL(base) &= ~MIXER_MIXER_SRC_STRUCT_SRC_FIFO_CTL_ACTIVE_Msk;
}

/*******************************************************************************
* Function Name: Cy_Mixer_Src_GetUsedFifoEntries
****************************************************************************//**
*
* Get the number of used/occupied entries in the source FIFO.
* The field value is in the range [0, 128]. When "0", the FIFO is empty. When "128", the FIFO is full.
*
* \param base pointer to the Mixer SRC Struct instance
*
* \return uint8_t number of used/occupied entries in the source FIFO
*
*******************************************************************************/
__STATIC_INLINE uint8_t Cy_Mixer_Src_GetUsedFifoEntries(volatile MIXER_SRC_STRUCT_Type * base)
{
    return (uint8_t)(_FLD2VAL(MIXER_MIXER_SRC_STRUCT_SRC_FIFO_STATUS_USED, MIXER_SRC_STRUCT_SRC_FIFO_STATUS(base)));
}

/*******************************************************************************
* Function Name: Cy_Mixer_Src_GetFifoReadPtr
****************************************************************************//**
*
* Get the source FIFO read pointer (Source FIFO location from which a data is read).
*
* \param base pointer to the Mixer SRC Struct instance
*
* \return uint8_t read pointer value
*
*******************************************************************************/
__STATIC_INLINE uint8_t Cy_Mixer_Src_GetFifoReadPtr(volatile MIXER_SRC_STRUCT_Type * base)
{
    return (uint8_t)(_FLD2VAL(MIXER_MIXER_SRC_STRUCT_SRC_FIFO_STATUS_RD_PTR, MIXER_SRC_STRUCT_SRC_FIFO_STATUS(base)));
}

/*******************************************************************************
* Function Name: Cy_Mixer_Src_GetFifoWritePtr
****************************************************************************//**
*
* Get the source FIFO write pointer (Source FIFO location at which new
* data is written by the hardware).
*
* \param base pointer to the Mixer SRC Struct instance
*
* \return uint8_t write pointer value
*
*******************************************************************************/
__STATIC_INLINE uint8_t Cy_Mixer_Src_GetFifoWritePtr(volatile MIXER_SRC_STRUCT_Type * base)
{
    return (uint8_t)(_FLD2VAL(MIXER_MIXER_SRC_STRUCT_SRC_FIFO_STATUS_WR_PTR, MIXER_SRC_STRUCT_SRC_FIFO_STATUS(base)));
}

/*******************************************************************************
* Function Name: Cy_Mixer_Src_FifoWriteData
****************************************************************************//**
*
* Data (PCM sample pair of two 16-bit samples) written to the top source FIFO
* entry (data[31:0] = DATA[31:0]). Typically, DATA[15:0] is used for channel 0
* and DATA[31:16] is used for channel 1. Writing adds the data to the source
* FIFO; i.e. behavior is similar to that of a PUSH operation.
*
* \param base pointer to the Mixer SRC Struct instance
* \param data 32-bit data
*
* \funcusage
* \snippet mixer/snippet/main.c snippet_Cy_Mixer_Src_FifoWriteData
*
*******************************************************************************/
__STATIC_INLINE void Cy_Mixer_Src_FifoWriteData(volatile MIXER_SRC_STRUCT_Type * base, uint32_t data)
{
    MIXER_SRC_STRUCT_SRC_FIFO_WR(base) = data;
}

/*******************************************************************************
* Function Name: Cy_Mixer_Src_ClearInterrupt
****************************************************************************//**
*
* Source interrupt clear (HW sets and SW clears)
*
* \param base pointer to the Mixer SRC Struct instance
* \param intSrc \ref cy_en_mixer_src_interrupt_t
*
* \funcusage
* \snippet mixer/snippet/main.c snippet_Cy_Mixer_Src_ClearInterrupt
*
*******************************************************************************/
__STATIC_INLINE void Cy_Mixer_Src_ClearInterrupt(volatile MIXER_SRC_STRUCT_Type * base, cy_en_mixer_src_interrupt_t intSrc)
{
    switch (intSrc)
    {
    case CY_MIXER_SRC_FIFO_TRIGGER:
        /* HW sets this field to '1', when a source trigger is generated. */
        MIXER_SRC_STRUCT_INTR_SRC(base) = MIXER_MIXER_SRC_STRUCT_INTR_SRC_FIFO_TRIGGER_Msk;
        break;
    case CY_MIXER_SRC_FIFO_OVERFLOW:
        /* HW sets this field to '1', when writing to a full source FIFO (SRC_FIFO_STATUS.USED is "128"). */
        MIXER_SRC_STRUCT_INTR_SRC(base) = MIXER_MIXER_SRC_STRUCT_INTR_SRC_FIFO_OVERFLOW_Msk;
        break;
    case CY_MIXER_SRC_FADE_OUT:
        /* HW sets this field to '1', when fade out has completed (HW changes SRC_FADE_CMD.FADE_OUT from "0" to "1"). */
        MIXER_SRC_STRUCT_INTR_SRC(base) = MIXER_MIXER_SRC_STRUCT_INTR_SRC_FADED_OUT_Msk;
        break;
    default:
        /* Invalid interrupt source */
        CY_ASSERT_L3(false);
        break;
    }
}

/*******************************************************************************
* Function Name: Cy_Mixer_Src_SetInterrupt
****************************************************************************//**
*
* Source interrupt set (Write this field with '1' to set corresponding INTR_SRC field)
*
* \param base pointer to the Mixer SRC Struct instance
* \param intSrc \ref cy_en_mixer_src_interrupt_t
*
*******************************************************************************/
__STATIC_INLINE void Cy_Mixer_Src_SetInterrupt(volatile MIXER_SRC_STRUCT_Type * base, cy_en_mixer_src_interrupt_t intSrc)
{
    switch (intSrc)
    {
    case CY_MIXER_SRC_FIFO_TRIGGER:
        MIXER_SRC_STRUCT_INTR_SRC_SET(base) = MIXER_MIXER_SRC_STRUCT_INTR_SRC_SET_FIFO_TRIGGER_Msk;
        break;
    case CY_MIXER_SRC_FIFO_OVERFLOW:
        MIXER_SRC_STRUCT_INTR_SRC_SET(base) = MIXER_MIXER_SRC_STRUCT_INTR_SRC_SET_FIFO_OVERFLOW_Msk;
        break;
    case CY_MIXER_SRC_FADE_OUT:
        MIXER_SRC_STRUCT_INTR_SRC_SET(base) = MIXER_MIXER_SRC_STRUCT_INTR_SRC_SET_FADED_OUT_Msk;
        break;
    default:
        /* Invalid interrupt source */
        CY_ASSERT_L3(false);
        break;
    }
}

/*******************************************************************************
* Function Name: Cy_Mixer_Src_ClearInterruptMask
****************************************************************************//**
*
* Source interrupt clear Mask for corresponding field in INTR_SRC register.
*
* \param base pointer to the Mixer SRC Struct instance
* \param intSrc \ref cy_en_mixer_src_interrupt_t
*
* \funcusage
* \snippet mixer/snippet/main.c snippet_Cy_Mixer_Src_SetInterruptMask
*
*******************************************************************************/
__STATIC_INLINE void Cy_Mixer_Src_ClearInterruptMask(volatile MIXER_SRC_STRUCT_Type * base, cy_en_mixer_src_interrupt_t intSrc)
{
    switch (intSrc)
    {
    case CY_MIXER_SRC_FIFO_TRIGGER:
        MIXER_SRC_STRUCT_INTR_SRC_MASK(base) &= ~MIXER_MIXER_SRC_STRUCT_INTR_SRC_MASK_FIFO_TRIGGER_Msk;
        break;
    case CY_MIXER_SRC_FIFO_OVERFLOW:
        MIXER_SRC_STRUCT_INTR_SRC_MASK(base) &= ~MIXER_MIXER_SRC_STRUCT_INTR_SRC_MASK_FIFO_OVERFLOW_Msk;
        break;
    case CY_MIXER_SRC_FADE_OUT:
        MIXER_SRC_STRUCT_INTR_SRC_MASK(base) &= ~MIXER_MIXER_SRC_STRUCT_INTR_SRC_MASK_FADED_OUT_Msk;
        break;
    default:
        /* Invalid interrupt source */
        CY_ASSERT_L3(false);
        break;
    }
}

/*******************************************************************************
* Function Name: Cy_Mixer_Src_SetInterruptMask
****************************************************************************//**
*
* Source interrupt set Mask for corresponding field in INTR_SRC register.
*
* \param base pointer to the Mixer SRC Struct instance
* \param intSrc \ref cy_en_mixer_src_interrupt_t
*
* \funcusage
* \snippet mixer/snippet/main.c snippet_Cy_Mixer_Src_SetInterruptMask
*
*******************************************************************************/
__STATIC_INLINE void Cy_Mixer_Src_SetInterruptMask(volatile MIXER_SRC_STRUCT_Type * base, cy_en_mixer_src_interrupt_t intSrc)
{
    switch (intSrc)
    {
    case CY_MIXER_SRC_FIFO_TRIGGER:
        MIXER_SRC_STRUCT_INTR_SRC_MASK(base) |= MIXER_MIXER_SRC_STRUCT_INTR_SRC_MASK_FIFO_TRIGGER_Msk;
        break;
    case CY_MIXER_SRC_FIFO_OVERFLOW:
        MIXER_SRC_STRUCT_INTR_SRC_MASK(base) |= MIXER_MIXER_SRC_STRUCT_INTR_SRC_MASK_FIFO_OVERFLOW_Msk;
        break;
    case CY_MIXER_SRC_FADE_OUT:
        MIXER_SRC_STRUCT_INTR_SRC_MASK(base) |= MIXER_MIXER_SRC_STRUCT_INTR_SRC_MASK_FADED_OUT_Msk;
        break;
    default:
        /* Invalid interrupt source */
        CY_ASSERT_L3(false);
        break;
    }
}

/*******************************************************************************
* Function Name: Cy_Mixer_Src_IsInterruptActive
****************************************************************************//**
*
* Get source interrupt active state.
*
* \param base pointer to the Mixer SRC Struct instance
* \param intSrc \ref cy_en_mixer_src_interrupt_t
*
* \return
* true: interrupt is set
* false: interrupt is not set
*
* \funcusage
* \snippet mixer/snippet/main.c snippet_Cy_Mixer_Src_ClearInterrupt
*
*******************************************************************************/
__STATIC_INLINE bool Cy_Mixer_Src_IsInterruptActive(volatile MIXER_SRC_STRUCT_Type * base, cy_en_mixer_src_interrupt_t intSrc)
{
    bool intActive = false;
    switch (intSrc)
    {
    case CY_MIXER_SRC_FIFO_TRIGGER:
        intActive = (0UL != (MIXER_SRC_STRUCT_INTR_SRC(base) & MIXER_MIXER_SRC_STRUCT_INTR_SRC_FIFO_TRIGGER_Msk));
        break;
    case CY_MIXER_SRC_FIFO_OVERFLOW:
        intActive = (0UL != (MIXER_SRC_STRUCT_INTR_SRC(base) & MIXER_MIXER_SRC_STRUCT_INTR_SRC_FIFO_OVERFLOW_Msk));
        break;
    case CY_MIXER_SRC_FADE_OUT:
        intActive = (0UL != (MIXER_SRC_STRUCT_INTR_SRC(base) & MIXER_MIXER_SRC_STRUCT_INTR_SRC_FADED_OUT_Msk));
        break;
    default:
        /* Invalid interrupt source */
        CY_ASSERT_L3(false);
        break;
    }

    return intActive;
}

/*******************************************************************************
* Function Name: Cy_Mixer_Dst_Enable
****************************************************************************//**
*
* Mixer destination enable
*
* \param base pointer to the Mixer DST Struct instance
*
* \funcusage
* \snippet mixer/snippet/main.c snippet_Cy_Mixer_DestinationInit
*
*******************************************************************************/
__STATIC_INLINE void Cy_Mixer_Dst_Enable(volatile MIXER_DST_STRUCT_Type * base)
{
    MIXER_DST_STRUCT_DST_CTL(base) = MIXER_MIXER_DST_STRUCT_DST_CTL_ENABLED_Msk;
}

/*******************************************************************************
* Function Name: Cy_Mixer_Dst_Disable
****************************************************************************//**
*
* Mixer destination disable
*
* \param base pointer to the Mixer DST Struct instance
*
* \funcusage
* \snippet mixer/snippet/main.c snippet_Cy_Mixer_Dst_Disable
*
*******************************************************************************/
__STATIC_INLINE void Cy_Mixer_Dst_Disable(volatile MIXER_DST_STRUCT_Type * base)
{
    MIXER_DST_STRUCT_DST_CTL(base) = 0UL;
}

/*******************************************************************************
* Function Name: Cy_Mixer_Dst_FadeControl
****************************************************************************//**
*
* Set the destination fade control (Gain code in the range [0, 115])
*
* \param base pointer to the Mixer DST Struct instance
* \param fadeCode \ref cy_en_mixer_fade_code_t
*
*******************************************************************************/
__STATIC_INLINE void Cy_Mixer_Dst_FadeControl(volatile MIXER_DST_STRUCT_Type * base, cy_en_mixer_fade_code_t fadeCode)
{
    MIXER_DST_STRUCT_DST_FADE_CTL(base) = _VAL2FLD(MIXER_MIXER_DST_STRUCT_DST_FADE_CTL_CODE, fadeCode);
}

/*******************************************************************************
* Function Name: Cy_Mixer_Dst_GetCurrentPace
****************************************************************************//**
*
* Get the Destination fading pace counter value.
* DST_FADE_CTL.PACE value of "n" reuses a specific fade value "n+1" times.
*
* \param base pointer to the Mixer DST Struct instance
*
* \return uint16_t fading pace counter value
*
*******************************************************************************/
__STATIC_INLINE uint16_t Cy_Mixer_Dst_GetCurrentPace(volatile MIXER_DST_STRUCT_Type * base)
{
    return (uint8_t)(_FLD2VAL(MIXER_MIXER_DST_STRUCT_DST_FADE_STATUS_PACE, MIXER_DST_STRUCT_DST_FADE_STATUS(base)));
}

/*******************************************************************************
* Function Name: Cy_Mixer_Dst_FadeInEnable
****************************************************************************//**
*
* Mixer destination fade in enable
*
* (SW sets this field to '1' to start "fade in" functionality. HW clears this
* field to '0' to indicate that "fade in" has completed) FADE_IN and FADE_OUT
* should be used mutually exclusively. However, if "fade in" is desired while
* "fading out", SW can set FADE_IN to '1' and clear FADE_OUT to '0'. "Fade in"
* will commence from the current CODE value. Similarly,  if "fade out" is
* desired while "fading in", SW can set FADE_OUT to '1' and clear FADE_IN to
* '0'. "Fade out" will commence from the current CODE value.
*
* \param base pointer to the Mixer DST Struct instance
*
* \funcusage
* \snippet mixer/snippet/main.c snippet_Cy_Mixer_Dst_FadeInEnable
*
*******************************************************************************/
__STATIC_INLINE void Cy_Mixer_Dst_FadeInEnable(volatile MIXER_DST_STRUCT_Type * base)
{
    MIXER_DST_STRUCT_DST_FADE_CMD(base) |= MIXER_MIXER_DST_STRUCT_DST_FADE_CMD_FADE_IN_Msk;
}

/*******************************************************************************
* Function Name: Cy_Mixer_Dst_FadeInDisable
****************************************************************************//**
*
* Mixer destination fade in disable
*
* \param base pointer to the Mixer DST Struct instance
*
*******************************************************************************/
__STATIC_INLINE void Cy_Mixer_Dst_FadeInDisable(volatile MIXER_DST_STRUCT_Type * base)
{
    MIXER_DST_STRUCT_DST_FADE_CMD(base) &= ~MIXER_MIXER_DST_STRUCT_DST_FADE_CMD_FADE_IN_Msk;
}

/*******************************************************************************
* Function Name: Cy_Mixer_Dst_FadeOutEnable
****************************************************************************//**
*
* Mixer destination fade out enable
*
* \param base pointer to the Mixer DST Struct instance
*
* \funcusage
* \snippet mixer/snippet/main.c snippet_Cy_Mixer_Dst_FadeOutEnable
*
*******************************************************************************/
__STATIC_INLINE void Cy_Mixer_Dst_FadeOutEnable(volatile MIXER_DST_STRUCT_Type * base)
{
    MIXER_DST_STRUCT_DST_FADE_CMD(base) |= MIXER_MIXER_DST_STRUCT_DST_FADE_CMD_FADE_OUT_Msk;
}

/*******************************************************************************
* Function Name: Cy_Mixer_Dst_FadeOutDisable
****************************************************************************//**
*
* Mixer destination fade out disable
*
* \param base pointer to the Mixer DST Struct instance
*
*******************************************************************************/
__STATIC_INLINE void Cy_Mixer_Dst_FadeOutDisable(volatile MIXER_DST_STRUCT_Type * base)
{
    MIXER_DST_STRUCT_DST_FADE_CMD(base) &= ~MIXER_MIXER_DST_STRUCT_DST_FADE_CMD_FADE_OUT_Msk;
}

/*******************************************************************************
* Function Name: Cy_Mixer_Dst_AutoFadeActivate
****************************************************************************//**
*
* Configures the mixer destination to NOT deactivate when "fade out" completes
*
* \param base pointer to the Mixer DST Struct instance
*
*******************************************************************************/
__STATIC_INLINE void Cy_Mixer_Dst_AutoFadeActivate(volatile MIXER_DST_STRUCT_Type * base)
{
    MIXER_DST_STRUCT_DST_FADE_CMD(base) &= ~MIXER_MIXER_DST_STRUCT_DST_FADE_CMD_AUTO_DEACTIVATE_Msk;
}

/*******************************************************************************
* Function Name: Cy_Mixer_Dst_AutoFadeDeactivate
****************************************************************************//**
*
* Configures the mixer destination to automatically deactivate when "fade out"
* completes
*
* \param base pointer to the Mixer DST Struct instance
*
* \funcusage
* \snippet mixer/snippet/main.c snippet_Cy_Mixer_Dst_FadeOutEnable
*
*******************************************************************************/
__STATIC_INLINE void Cy_Mixer_Dst_AutoFadeDeactivate(volatile MIXER_DST_STRUCT_Type * base)
{
    MIXER_DST_STRUCT_DST_FADE_CMD(base) |= MIXER_MIXER_DST_STRUCT_DST_FADE_CMD_AUTO_DEACTIVATE_Msk;
}

/*******************************************************************************
* Function Name: Cy_Mixer_Dst_FadePaceSelect
****************************************************************************//**
*
* Destination fade pace select (Specifies the pace/speed of "fade in" and "fade out")
*
* \param base pointer to the Mixer DST Struct instance
* \param pace (10-bit value)
*          "0": The same CODE value is used (0+1) times,
*          "1": The same CODE value is used (1+1) times.
*          ...
*          "1023": The same CODE value is used (1023+1) times.
*           A fade in from "mute" to 0 dB takes 1024*116 = 118,784 PCM samples. At a PCM sample frequency
*           Fs of 48 kHz, this translates into 118,784/48,000 = 2.474 seconds.
*
* \funcusage
* \snippet mixer/snippet/main.c snippet_Cy_Mixer_Dst_FadeInEnable
*
*******************************************************************************/
__STATIC_INLINE void Cy_Mixer_Dst_FadePaceSelect(volatile MIXER_DST_STRUCT_Type * base, uint16_t pace)
{
    CY_REG32_CLR_SET(MIXER_DST_STRUCT_DST_FADE_CMD(base), MIXER_MIXER_DST_STRUCT_DST_FADE_CMD_PACE, pace);
}

/*******************************************************************************
* Function Name: Cy_Mixer_Dst_GainCodeSelect
****************************************************************************//**
*
* Set the destination gain code in the range [0, 127].
* Each gain code increment represents 1 dB. Gain code value "0" represents
* digital mute. Gain code "127" represents a maximum amplification of 12 dB.
*
* \param base pointer to the Mixer DST Struct instance
* \param code (7-bit value)
*          "0": digital mute. Multiplier value is "0" and "shift" is "26".
*          "1": -114 dB. Multiplier value is "134" and "shift" is "26".
*          "2": -113 dB. Multiplier value is "150" and "shift" is "26".
*          "3": -112 dB. Multiplier value is "169" and "shift" is "26".
*          ...
*          "115": 0 dB. Multiplier value is "4096" and "shift" is "12". Note that (4096 * x) >> 12 = x; i.e. the PCM value is unaffected.
*          ...
*          "121": 6 dB. Multiplier value is "8173" and "shift" is "12".
*          ...
*          "127": 12 dB. Multiplier value is "8153" and "shift" is "11".
*
*******************************************************************************/
__STATIC_INLINE void Cy_Mixer_Dst_GainCodeSelect(volatile MIXER_DST_STRUCT_Type * base, uint8_t code)
{
    MIXER_DST_STRUCT_DST_GAIN_CTL(base) = _VAL2FLD(MIXER_MIXER_DST_STRUCT_DST_GAIN_CTL_CODE, code);
}

/*******************************************************************************
* Function Name: Cy_Mixer_Dst_FifoTriggerLevel
****************************************************************************//**
*
* Destination FIFO trigger level. When the destination FIFO has more entries
* than the number of this field, a transmitter trigger event is generated.
*
* \param base pointer to the Mixer DST Struct instance
* \param level (6-bit value) (INTR_SRC.FIFO_TRIGGER = (# FIFO entries > TRIGGER_LEVEL))
*
*******************************************************************************/
__STATIC_INLINE void Cy_Mixer_Dst_FifoTriggerLevel(volatile MIXER_DST_STRUCT_Type * base, uint8_t level)
{
    CY_REG32_CLR_SET(MIXER_DST_STRUCT_DST_FIFO_CTL(base), MIXER_MIXER_DST_STRUCT_DST_FIFO_CTL_TRIGGER_LEVEL, level);
}

/*******************************************************************************
* Function Name: Cy_Mixer_Dst_Mute
****************************************************************************//**
*
* Mixer destination mute
*
* \param base pointer to the Mixer DST Struct instance
*
* \funcusage
* \snippet mixer/snippet/main.c snippet_Cy_Mixer_Dst_Mute
*
*******************************************************************************/
__STATIC_INLINE void Cy_Mixer_Dst_Mute(volatile MIXER_DST_STRUCT_Type * base)
{
    MIXER_DST_STRUCT_DST_FIFO_CTL(base) |= MIXER_MIXER_DST_STRUCT_DST_FIFO_CTL_MUTE_Msk;
}

/*******************************************************************************
* Function Name: Cy_Mixer_Dst_Unmute
****************************************************************************//**
*
* Mixer destination unmute
*
* \param base pointer to the Mixer DST Struct instance
*
* \funcusage
* \snippet mixer/snippet/main.c snippet_Cy_Mixer_Dst_Unmute
*
*******************************************************************************/
__STATIC_INLINE void Cy_Mixer_Dst_Unmute(volatile MIXER_DST_STRUCT_Type * base)
{
    MIXER_DST_STRUCT_DST_FIFO_CTL(base) &= ~MIXER_MIXER_DST_STRUCT_DST_FIFO_CTL_MUTE_Msk;
}

/*******************************************************************************
* Function Name: Cy_Mixer_Dst_Activate
****************************************************************************//**
*
* Activate the mixer destination
*
* \param base pointer to the Mixer DST Struct instance
*
* \funcusage
* \snippet mixer/snippet/main.c snippet_Cy_Mixer_DestinationInit
*
*******************************************************************************/
__STATIC_INLINE void Cy_Mixer_Dst_Activate(volatile MIXER_DST_STRUCT_Type * base)
{
    MIXER_DST_STRUCT_DST_FIFO_CTL(base) |= MIXER_MIXER_DST_STRUCT_DST_FIFO_CTL_ACTIVE_Msk;
}

/*******************************************************************************
* Function Name: Cy_Mixer_Dst_Deactivate
****************************************************************************//**
*
* Deactivate the mixer destination
*
* \param base pointer to the Mixer DST Struct instance
*
* \funcusage
* \snippet mixer/snippet/main.c snippet_Cy_Mixer_Dst_Disable
*
*******************************************************************************/
__STATIC_INLINE void Cy_Mixer_Dst_Deactivate(volatile MIXER_DST_STRUCT_Type * base)
{
    MIXER_DST_STRUCT_DST_FIFO_CTL(base) &= ~MIXER_MIXER_DST_STRUCT_DST_FIFO_CTL_ACTIVE_Msk;
}

/*******************************************************************************
* Function Name: Cy_Mixer_Dst_GetUsedFifoEntries
****************************************************************************//**
*
* Number of used/occupied entries in the destination FIFO.
* The field value is in the range [0, 128]. When "0", the FIFO is empty.
* When "128", the FIFO is full.
*
* \param base pointer to the Mixer DST Struct instance
*
* \return uint8_t number of used/occupied entries in the destination FIFO
*
*******************************************************************************/
__STATIC_INLINE uint8_t Cy_Mixer_Dst_GetUsedFifoEntries(volatile MIXER_DST_STRUCT_Type * base)
{
    return (uint8_t)(_FLD2VAL(MIXER_MIXER_DST_STRUCT_DST_FIFO_STATUS_USED, MIXER_DST_STRUCT_DST_FIFO_STATUS(base)));
}

/*******************************************************************************
* Function Name: Cy_Mixer_Dst_GetFifoReadPtr
****************************************************************************//**
*
* Get the destination FIFO read pointer (Destination FIFO location from which a data is read).
*
* \param base pointer to the Mixer DST Struct instance
*
* \return uint8_t read pointer value
*
*******************************************************************************/
__STATIC_INLINE uint8_t Cy_Mixer_Dst_GetFifoReadPtr(volatile MIXER_DST_STRUCT_Type * base)
{
    return (uint8_t)(_FLD2VAL(MIXER_MIXER_DST_STRUCT_DST_FIFO_STATUS_RD_PTR, MIXER_DST_STRUCT_DST_FIFO_STATUS(base)));
}

/*******************************************************************************
* Function Name: Cy_Mixer_Dst_GetFifoWritePtr
****************************************************************************//**
*
* Get the destination FIFO write pointer (Destination FIFO location at which
* new data is written by the hardware).
*
* \param base pointer to the Mixer DST Struct instance
*
* \return uint8_t write pointer value
*
*******************************************************************************/
__STATIC_INLINE uint8_t Cy_Mixer_Dst_GetFifoWritePtr(volatile MIXER_DST_STRUCT_Type * base)
{
    return (uint8_t)(_FLD2VAL(MIXER_MIXER_DST_STRUCT_DST_FIFO_STATUS_WR_PTR, MIXER_DST_STRUCT_DST_FIFO_STATUS(base)));
}

/*******************************************************************************
* Function Name: Cy_Mixer_Dst_FifoReadData
****************************************************************************//**
*
* Read data (PCM sample pair of two 16-bit samples) at the top destination
* FIFO entry (data[31:0] = DATA[31:0]). Reading removes the data from the
* destination FIFO; i.e. behavior is similar to that of a POP operation
* (DST_FIFO_STATUS.RD_PTR is incremented and DST_FIFO_STATUS.USED is decremented).
*
* \param base pointer to the Mixer DST Struct instance
*
* \return uint32_t FIFO data sample
*
* \funcusage
* \snippet mixer/snippet/main.c snippet_Cy_Mixer_Dst_FifoReadData
*
*******************************************************************************/
__STATIC_INLINE uint32_t Cy_Mixer_Dst_FifoReadData(volatile MIXER_DST_STRUCT_Type * base)
{
    return MIXER_DST_STRUCT_DST_FIFO_RD(base);
}

/*******************************************************************************
* Function Name: Cy_Mixer_Dst_ClearInterrupt
****************************************************************************//**
*
* Destination interrupt clear (HW sets and SW clears)
*
* \param base pointer to the Mixer DST Struct instance
* \param intSrc \ref cy_en_mixer_dst_interrupt_t
*
* \funcusage
* \snippet mixer/snippet/main.c snippet_Cy_Mixer_Dst_ClearInterrupt
*
*******************************************************************************/
__STATIC_INLINE void Cy_Mixer_Dst_ClearInterrupt(volatile MIXER_DST_STRUCT_Type * base, cy_en_mixer_dst_interrupt_t intSrc)
{
    switch (intSrc)
    {
    case CY_MIXER_DST_FIFO_TRIGGER:
        MIXER_DST_STRUCT_INTR_DST(base) = MIXER_MIXER_DST_STRUCT_INTR_DST_FIFO_TRIGGER_Msk;
        break;
    case CY_MIXER_DST_FIFO_UNDERFLOW:
        MIXER_DST_STRUCT_INTR_DST(base) = MIXER_MIXER_DST_STRUCT_INTR_DST_FIFO_UNDERFLOW_Msk;
        break;
    case CY_MIXER_DST_FADE_OUT:
        MIXER_DST_STRUCT_INTR_DST(base) = MIXER_MIXER_DST_STRUCT_INTR_DST_FADED_OUT_Msk;
        break;
    default:
        /* Invalid interrupt source */
        CY_ASSERT_L3(false);
        break;
    }
}

/*******************************************************************************
* Function Name: Cy_Mixer_Dst_SetInterrupt
****************************************************************************//**
*
* Destination interrupt set (Write this field with '1' to set corresponding INTR_DST field)
*
* \param base pointer to the Mixer DST Struct instance
* \param intSrc \ref cy_en_mixer_dst_interrupt_t
*
*******************************************************************************/
__STATIC_INLINE void Cy_Mixer_Dst_SetInterrupt(volatile MIXER_DST_STRUCT_Type * base, cy_en_mixer_dst_interrupt_t intSrc)
{
    switch (intSrc)
    {
    case CY_MIXER_DST_FIFO_TRIGGER:
        MIXER_DST_STRUCT_INTR_DST_SET(base) = MIXER_MIXER_DST_STRUCT_INTR_DST_SET_FIFO_TRIGGER_Msk;
        break;
    case CY_MIXER_DST_FIFO_UNDERFLOW:
        MIXER_DST_STRUCT_INTR_DST_SET(base) = MIXER_MIXER_DST_STRUCT_INTR_DST_SET_FIFO_UNDERFLOW_Msk;
        break;
    case CY_MIXER_DST_FADE_OUT:
        MIXER_DST_STRUCT_INTR_DST_SET(base) = MIXER_MIXER_DST_STRUCT_INTR_DST_SET_FADED_OUT_Msk;
        break;
    default:
        /* Invalid interrupt source */
        CY_ASSERT_L3(false);
        break;
    }
}

/*******************************************************************************
* Function Name: Cy_Mixer_Dst_ClearInterruptMask
****************************************************************************//**
*
* Destination interrupt clear Mask for corresponding field in INTR_DST register.
*
* \param base pointer to the Mixer DST Struct instance
* \param intSrc \ref cy_en_mixer_dst_interrupt_t
*
* \funcusage
* \snippet mixer/snippet/main.c snippet_Cy_Mixer_Dst_SetInterruptMask
*
*******************************************************************************/
__STATIC_INLINE void Cy_Mixer_Dst_ClearInterruptMask(volatile MIXER_DST_STRUCT_Type * base, cy_en_mixer_dst_interrupt_t intSrc)
{
    switch (intSrc)
    {
    case CY_MIXER_DST_FIFO_TRIGGER:
        MIXER_DST_STRUCT_INTR_DST_MASK(base) &= ~MIXER_MIXER_DST_STRUCT_INTR_DST_MASK_FIFO_TRIGGER_Msk;
        break;
    case CY_MIXER_DST_FIFO_UNDERFLOW:
        MIXER_DST_STRUCT_INTR_DST_MASK(base) &= ~MIXER_MIXER_DST_STRUCT_INTR_DST_MASK_FIFO_UNDERFLOW_Msk;
        break;
    case CY_MIXER_DST_FADE_OUT:
        MIXER_DST_STRUCT_INTR_DST_MASK(base) &= ~MIXER_MIXER_DST_STRUCT_INTR_DST_MASK_FADED_OUT_Msk;
        break;
    default:
        /* Invalid interrupt source */
        CY_ASSERT_L3(false);
        break;
    }
}

/*******************************************************************************
* Function Name: Cy_Mixer_Dst_SetInterruptMask
****************************************************************************//**
*
* Destination interrupt set Mask for corresponding field in INTR_DST register.
*
* \param base pointer to the Mixer DST Struct instance
* \param intSrc \ref cy_en_mixer_dst_interrupt_t
*
* \funcusage
* \snippet mixer/snippet/main.c snippet_Cy_Mixer_Dst_SetInterruptMask
*
*******************************************************************************/
__STATIC_INLINE void Cy_Mixer_Dst_SetInterruptMask(volatile MIXER_DST_STRUCT_Type * base, cy_en_mixer_dst_interrupt_t intSrc)
{
    switch (intSrc)
    {
    case CY_MIXER_DST_FIFO_TRIGGER:
        MIXER_DST_STRUCT_INTR_DST_MASK(base) |= MIXER_MIXER_DST_STRUCT_INTR_DST_MASK_FIFO_TRIGGER_Msk;
        break;
    case CY_MIXER_DST_FIFO_UNDERFLOW:
        MIXER_DST_STRUCT_INTR_DST_MASK(base) |= MIXER_MIXER_DST_STRUCT_INTR_DST_MASK_FIFO_UNDERFLOW_Msk;
        break;
    case CY_MIXER_DST_FADE_OUT:
        MIXER_DST_STRUCT_INTR_DST_MASK(base) |= MIXER_MIXER_DST_STRUCT_INTR_DST_MASK_FADED_OUT_Msk;
        break;
    default:
        /* Invalid interrupt source */
        CY_ASSERT_L3(false);
        break;
    }
}

/*******************************************************************************
* Function Name: Cy_Mixer_Dst_IsInterruptActive
****************************************************************************//**
*
* Get destination interrupt active state.
*
* \param base pointer to the Mixer DST Struct instance
* \param intSrc \ref cy_en_mixer_dst_interrupt_t
*
* \return
* true: interrupt is set
* false: interrupt is not set
*
* \funcusage
* \snippet mixer/snippet/main.c snippet_Cy_Mixer_Dst_ClearInterrupt
*
*******************************************************************************/
__STATIC_INLINE bool Cy_Mixer_Dst_IsInterruptActive(volatile MIXER_DST_STRUCT_Type * base, cy_en_mixer_dst_interrupt_t intSrc)
{
    bool intActive = false;

    switch (intSrc)
    {
    case CY_MIXER_DST_FIFO_TRIGGER:
        intActive = (0UL != (MIXER_DST_STRUCT_INTR_DST(base) & MIXER_MIXER_DST_STRUCT_INTR_DST_FIFO_TRIGGER_Msk));
        break;
    case CY_MIXER_DST_FIFO_UNDERFLOW:
        intActive = (0UL != (MIXER_DST_STRUCT_INTR_DST(base) & MIXER_MIXER_DST_STRUCT_INTR_DST_FIFO_UNDERFLOW_Msk));
        break;
    case CY_MIXER_DST_FADE_OUT:
        intActive = (0UL != (MIXER_DST_STRUCT_INTR_DST(base) & MIXER_MIXER_DST_STRUCT_INTR_DST_FADED_OUT_Msk));
        break;
    default:
        /* Invalid interrupt source */
        CY_ASSERT_L3(false);
        break;
    }

    return intActive;
}

#if (defined(MIXER0_TX_PRESENT) && (MIXER0_TX_PRESENT == 1)) || (defined(MIXER1_TX_PRESENT) && (MIXER1_TX_PRESENT == 1))
/*******************************************************************************
* Function Name: Cy_Mixer_Tx_Enable
****************************************************************************//**
*
* Enable the Mixer Transmitter
*
* \param base pointer to the Mixer TX Struct instance
*
* \funcusage
* \snippet mixer/snippet/main.c snippet_Cy_Mixer_TransmitInit
*
*******************************************************************************/
__STATIC_INLINE void Cy_Mixer_Tx_Enable(volatile MIXER_TX_STRUCT_Type * base)
{
    MIXER_TX_STRUCT_TX_CTL(base) |= MIXER_MIXER_TX_STRUCT_TX_CTL_ENABLED_Msk;
}

/*******************************************************************************
* Function Name: Cy_Mixer_Tx_Disable
****************************************************************************//**
*
* Disable the Mixer Transmitter
*
* \param base pointer to the Mixer TX Struct instance
*
* \funcusage
* \snippet mixer/snippet/main.c snippet_Cy_Mixer_Tx_Disable
*
*******************************************************************************/
__STATIC_INLINE void Cy_Mixer_Tx_Disable(volatile MIXER_TX_STRUCT_Type * base)
{
    MIXER_TX_STRUCT_TX_CTL(base) &= ~MIXER_MIXER_TX_STRUCT_TX_CTL_ENABLED_Msk;
}

/*******************************************************************************
* Function Name: Cy_Mixer_Tx_WordSize
****************************************************************************//**
*
* Set the Mixer Transmitter word size
*
* \param base pointer to the Mixer TX Struct instance
* \param wdSize \ref cy_en_mixer_tx_wd_size_t
*
*******************************************************************************/
__STATIC_INLINE void Cy_Mixer_Tx_WordSize(volatile MIXER_TX_STRUCT_Type * base, cy_en_mixer_tx_wd_size_t wdSize)
{
    CY_REG32_CLR_SET(MIXER_TX_STRUCT_TX_CTL(base), MIXER_MIXER_TX_STRUCT_TX_CTL_WORD_SIZE, wdSize);
}

/*******************************************************************************
* Function Name: Cy_Mixer_Tx_Format
****************************************************************************//**
*
* Set the Mixer Transmitter I2S format
*
* \param base pointer to the Mixer TX Struct instance
* \param format \ref cy_en_mixer_tx_fmt_t
*
*******************************************************************************/
__STATIC_INLINE void Cy_Mixer_Tx_Format(volatile MIXER_TX_STRUCT_Type * base, cy_en_mixer_tx_fmt_t format)
{
    CY_REG32_CLR_SET(MIXER_TX_STRUCT_TX_CTL(base), MIXER_MIXER_TX_STRUCT_TX_CTL_FORMAT, format);
}

/*******************************************************************************
* Function Name: Cy_Mixer_Tx_SelectMode
****************************************************************************//**
*
* Set the Mixer Transmitter Mode
*
* \param base pointer to the Mixer TX Struct instance
* \param mode \ref cy_en_mixer_tx_mode_t
*
*******************************************************************************/
__STATIC_INLINE void Cy_Mixer_Tx_SelectMode(volatile MIXER_TX_STRUCT_Type * base, cy_en_mixer_tx_mode_t mode)
{
    CY_REG32_CLR_SET(MIXER_TX_STRUCT_TX_CTL(base), MIXER_MIXER_TX_STRUCT_TX_CTL_MS, mode);
}

/*******************************************************************************
* Function Name: Cy_Mixer_Tx_ClockDivider
****************************************************************************//**
*
* Select the Mixer Transmitter Clock divider
*
* \param base pointer to the Mixer TX Struct instance
* \param clkDiv divider value [1...255] 0->DIV_BY_1, 255->DIV_BY_256
*
*******************************************************************************/
__STATIC_INLINE void Cy_Mixer_Tx_ClockDivider(volatile MIXER_TX_STRUCT_Type * base, uint8_t clkDiv)
{
    CY_REG32_CLR_SET(MIXER_TX_STRUCT_TX_IF_CTL(base), MIXER_MIXER_TX_STRUCT_TX_IF_CTL_CLOCK_DIV, clkDiv);
}

/*******************************************************************************
* Function Name: Cy_Mixer_Tx_ClockSelect
****************************************************************************//**
*
* Select the Mixer Transmitter Clock
*
* \param base pointer to the Mixer TX Struct instance
* \param clkSel \ref cy_en_mixer_tx_clk_sel_t
*
*******************************************************************************/
__STATIC_INLINE void Cy_Mixer_Tx_ClockSelect(volatile MIXER_TX_STRUCT_Type * base, cy_en_mixer_tx_clk_sel_t clkSel)
{
    CY_REG32_CLR_SET(MIXER_TX_STRUCT_TX_IF_CTL(base), MIXER_MIXER_TX_STRUCT_TX_IF_CTL_CLOCK_SEL, clkSel);
}

/*******************************************************************************
* Function Name: Cy_Mixer_Tx_ClockPolarity
****************************************************************************//**
*
* Sets the Mixer transmitter clock polarity
*
* \param base pointer to the Mixer TX Struct instance
* \param polarity
* false = Clock signal is used "as is" \n
* true = Clock signal is inverted
*
*******************************************************************************/
__STATIC_INLINE void Cy_Mixer_Tx_ClockPolarity(volatile MIXER_TX_STRUCT_Type * base, bool polarity)
{
    if (polarity)
    {
        MIXER_TX_STRUCT_TX_IF_CTL(base) |= MIXER_MIXER_TX_STRUCT_TX_IF_CTL_SCK_POLARITY_Msk;
    }
    else
    {
        MIXER_TX_STRUCT_TX_IF_CTL(base) &= ~MIXER_MIXER_TX_STRUCT_TX_IF_CTL_SCK_POLARITY_Msk;
    }
}

/*******************************************************************************
* Function Name: Cy_Mixer_Tx_WordSelectPolarity
****************************************************************************//**
*
* Sets the Mixer transmitter word select polarity
*
* \param base pointer to the Mixer TX Struct instance
* \param polarity
* false = Word select signal is used "as is" \n
* true = Word select signal is inverted
*
*******************************************************************************/
__STATIC_INLINE void Cy_Mixer_Tx_WordSelectPolarity(volatile MIXER_TX_STRUCT_Type * base, bool polarity)
{
    if (polarity)
    {
        MIXER_TX_STRUCT_TX_IF_CTL(base) |= MIXER_MIXER_TX_STRUCT_TX_IF_CTL_WS_POLARITY_Msk;
    }
    else
    {
        MIXER_TX_STRUCT_TX_IF_CTL(base) &= ~MIXER_MIXER_TX_STRUCT_TX_IF_CTL_WS_POLARITY_Msk;
    }
}

/*******************************************************************************
* Function Name: Cy_Mixer_Tx_ChannelEnable
****************************************************************************//**
*
* Enables the selected Mixer channel
*
* \param base pointer to the Mixer TX Struct instance
* \param channel \ref cy_en_mixer_channel_t
*
*******************************************************************************/
__STATIC_INLINE void Cy_Mixer_Tx_ChannelEnable(volatile MIXER_TX_STRUCT_Type * base, cy_en_mixer_channel_t channel)
{
    if (channel == CY_MIXER_CHANNEL0)
    {
        MIXER_TX_STRUCT_TX_IF_CTL(base) |= MIXER_MIXER_TX_STRUCT_TX_IF_CTL_CH0_EN_Msk;
    }
    else /* (channel == CY_MIXER_CHANNEL1) */
    {
        MIXER_TX_STRUCT_TX_IF_CTL(base) |= MIXER_MIXER_TX_STRUCT_TX_IF_CTL_CH1_EN_Msk;
    }
}

/*******************************************************************************
* Function Name: Cy_Mixer_Tx_ChannelDisable
****************************************************************************//**
*
* Disables the selected Mixer channel
*
* \param base pointer to the Mixer TX Struct instance
* \param channel \ref cy_en_mixer_channel_t
*
*******************************************************************************/
__STATIC_INLINE void Cy_Mixer_Tx_ChannelDisable(volatile MIXER_TX_STRUCT_Type * base, cy_en_mixer_channel_t channel)
{
    if (channel == CY_MIXER_CHANNEL0)
    {
        MIXER_TX_STRUCT_TX_IF_CTL(base) &= ~MIXER_MIXER_TX_STRUCT_TX_IF_CTL_CH0_EN_Msk;
    }
    else /* (channel == CY_MIXER_CHANNEL1) */
    {
        MIXER_TX_STRUCT_TX_IF_CTL(base) &= ~MIXER_MIXER_TX_STRUCT_TX_IF_CTL_CH1_EN_Msk;
    }
}

/*******************************************************************************
* Function Name: Cy_Mixer_Tx_ChannelSize
****************************************************************************//**
*
* Set the Mixer Transmitter Channel Size
*
* \param base pointer to the Mixer TX Struct instance
* \param chSize divider value [1...31] 0->SIZE_1, 31->SIZE_32
*
*******************************************************************************/
__STATIC_INLINE void Cy_Mixer_Tx_ChannelSize(volatile MIXER_TX_STRUCT_Type * base, uint8_t chSize)
{
    CY_REG32_CLR_SET(MIXER_TX_STRUCT_TX_IF_CTL(base), MIXER_MIXER_TX_STRUCT_TX_IF_CTL_CH_SIZE, chSize);
}

/*******************************************************************************
* Function Name: Cy_Mixer_Tx_Mute
****************************************************************************//**
*
* Mixer transmitter mute (HW uses a constant PCM data value of "0". Mute does advance the FIFO read pointer.)
*
* \param base pointer to the Mixer TX Struct instance
*
* \funcusage
* \snippet mixer/snippet/main.c snippet_Cy_Mixer_Tx_Mute
*
*******************************************************************************/
__STATIC_INLINE void Cy_Mixer_Tx_Mute(volatile MIXER_TX_STRUCT_Type * base)
{
    MIXER_TX_STRUCT_TX_FIFO_CTL(base) |= MIXER_MIXER_TX_STRUCT_TX_FIFO_CTL_MUTE_Msk;
}

/*******************************************************************************
* Function Name: Cy_Mixer_Tx_Unmute
****************************************************************************//**
*
* Mixer transmitter unmute (HW uses destination (TX) FIFO data)
*
* \param base pointer to the Mixer TX Struct instance
*
* \funcusage
* \snippet mixer/snippet/main.c snippet_Cy_Mixer_Tx_Unmute
*
*******************************************************************************/
__STATIC_INLINE void Cy_Mixer_Tx_Unmute(volatile MIXER_TX_STRUCT_Type * base)
{
    MIXER_TX_STRUCT_TX_FIFO_CTL(base) &= ~MIXER_MIXER_TX_STRUCT_TX_FIFO_CTL_MUTE_Msk;
}

/*******************************************************************************
* Function Name: Cy_Mixer_Tx_ActivateTransmitter
****************************************************************************//**
*
* Activate or deactivate the Mixer transmitter
*
* \param base pointer to the Mixer TX Struct instance
* \param state
* true = transmitter on \n
* false = transmitter off
*
* \funcusage
* \snippet mixer/snippet/main.c snippet_Cy_Mixer_TransmitInit
*
*******************************************************************************/
__STATIC_INLINE void Cy_Mixer_Tx_ActivateTransmitter(volatile MIXER_TX_STRUCT_Type * base, bool state)
{
    if (state)
    {
        MIXER_TX_STRUCT_TX_FIFO_CTL(base) |= MIXER_MIXER_TX_STRUCT_TX_FIFO_CTL_ACTIVE_Msk;
    }
    else
    {
        MIXER_TX_STRUCT_TX_FIFO_CTL(base) &= ~MIXER_MIXER_TX_STRUCT_TX_FIFO_CTL_ACTIVE_Msk;
    }
}

/*******************************************************************************
* Function Name: Cy_Mixer_Tx_Replay
****************************************************************************//**
*
* Mixer transmitter replay control
*
* \param base pointer to the Mixer TX Struct instance
* \param state
* true = replay on (HW uses previous PCM data value) \n
* false = replay off (HW uses a constant PCM data value of "0")
*
*******************************************************************************/
__STATIC_INLINE void Cy_Mixer_Tx_Replay(volatile MIXER_TX_STRUCT_Type * base, bool state)
{
    if (state)
    {
        MIXER_TX_STRUCT_TX_FIFO_CTL(base) |= MIXER_MIXER_TX_STRUCT_TX_FIFO_CTL_REPLAY_Msk;
    }
    else
    {
        MIXER_TX_STRUCT_TX_FIFO_CTL(base) &= ~MIXER_MIXER_TX_STRUCT_TX_FIFO_CTL_REPLAY_Msk;
    }
}

/*******************************************************************************
* Function Name: Cy_Mixer_Tx_ClearInterrupt
****************************************************************************//**
*
* Mixer Tx Interrupt Clear
*
* \param base pointer to the Mixer TX Struct instance
* \param intSrc \ref cy_stc_mixer_tx_int_src_t
*
* \funcusage
* \snippet mixer/snippet/main.c snippet_Cy_Mixer_Tx_ClearInterrupt
*
*******************************************************************************/
__STATIC_INLINE void Cy_Mixer_Tx_ClearInterrupt(volatile MIXER_TX_STRUCT_Type * base, cy_stc_mixer_tx_int_src_t intSrc)
{
    switch (intSrc)
    {
    case CY_MIXER_TX_FIFO_UNDERFLOW:
        MIXER_TX_STRUCT_INTR_TX(base) = MIXER_MIXER_TX_STRUCT_INTR_TX_FIFO_UNDERFLOW_Msk;
        break;
    case CY_MIXER_TX_IFC_UNDERFLOW:
        MIXER_TX_STRUCT_INTR_TX(base) = MIXER_MIXER_TX_STRUCT_INTR_TX_IF_UNDERFLOW_Msk;
        break;
    default:
        /* Invalid interrupt source */
        CY_ASSERT_L3(false);
        break;
    }
}

/*******************************************************************************
* Function Name: Cy_Mixer_Tx_SetInterrupt
****************************************************************************//**
*
* Mixer Tx Interrupt Set
*
* \param base pointer to the Mixer TX Struct instance
* \param intSrc \ref cy_stc_mixer_tx_int_src_t
*
*******************************************************************************/
__STATIC_INLINE void Cy_Mixer_Tx_SetInterrupt(volatile MIXER_TX_STRUCT_Type * base, cy_stc_mixer_tx_int_src_t intSrc)
{
    switch (intSrc)
    {
    case CY_MIXER_TX_FIFO_UNDERFLOW:
        MIXER_TX_STRUCT_INTR_TX_SET(base) = MIXER_MIXER_TX_STRUCT_INTR_TX_SET_FIFO_UNDERFLOW_Msk;
        break;
    case CY_MIXER_TX_IFC_UNDERFLOW:
        MIXER_TX_STRUCT_INTR_TX_SET(base) = MIXER_MIXER_TX_STRUCT_INTR_TX_SET_IF_UNDERFLOW_Msk;
        break;
    default:
        /* Invalid interrupt source */
        CY_ASSERT_L3(false);
        break;
    }
}

/*******************************************************************************
* Function Name: Cy_Mixer_Tx_ClearInterruptMask
****************************************************************************//**
*
* Mixer Tx Interrupt Mask Clear
*
* \param base pointer to the Mixer TX Struct instance
* \param intSrc \ref cy_stc_mixer_tx_int_src_t
*
* \funcusage
* \snippet mixer/snippet/main.c snippet_Cy_Mixer_Tx_SetInterruptMask
*
*******************************************************************************/
__STATIC_INLINE void Cy_Mixer_Tx_ClearInterruptMask(volatile MIXER_TX_STRUCT_Type * base, cy_stc_mixer_tx_int_src_t intSrc)
{
    switch (intSrc)
    {
    case CY_MIXER_TX_FIFO_UNDERFLOW:
        MIXER_TX_STRUCT_INTR_TX_MASK(base) &= ~MIXER_MIXER_TX_STRUCT_INTR_TX_MASK_FIFO_UNDERFLOW_Msk;
        break;
    case CY_MIXER_TX_IFC_UNDERFLOW:
        MIXER_TX_STRUCT_INTR_TX_MASK(base) &= ~MIXER_MIXER_TX_STRUCT_INTR_TX_MASK_IF_UNDERFLOW_Msk;
        break;
    default:
        /* Invalid interrupt source */
        CY_ASSERT_L3(false);
        break;
    }
}

/*******************************************************************************
* Function Name: Cy_Mixer_Tx_SetInterruptMask
****************************************************************************//**
*
* Mixer Tx Interrupt Mask Set
*
* \param base pointer to the Mixer TX Struct instance
* \param intSrc \ref cy_stc_mixer_tx_int_src_t
*
* \funcusage
* \snippet mixer/snippet/main.c snippet_Cy_Mixer_Tx_SetInterruptMask
*
*******************************************************************************/
__STATIC_INLINE void Cy_Mixer_Tx_SetInterruptMask(volatile MIXER_TX_STRUCT_Type * base, cy_stc_mixer_tx_int_src_t intSrc)
{
    switch (intSrc)
    {
    case CY_MIXER_TX_FIFO_UNDERFLOW:
        MIXER_TX_STRUCT_INTR_TX_MASK(base) |= MIXER_MIXER_TX_STRUCT_INTR_TX_MASK_FIFO_UNDERFLOW_Msk;
        break;
    case CY_MIXER_TX_IFC_UNDERFLOW:
        MIXER_TX_STRUCT_INTR_TX_MASK(base) |= MIXER_MIXER_TX_STRUCT_INTR_TX_MASK_IF_UNDERFLOW_Msk;
        break;
    default:
        /* Invalid interrupt source */
        CY_ASSERT_L3(false);
        break;
    }
}

/*******************************************************************************
* Function Name: Cy_Mixer_Tx_IsInterruptActive
****************************************************************************//**
*
* Get transmitter interrupt active state.
*
* \param base pointer to the Mixer TX Struct instance
* \param intSrc \ref cy_stc_mixer_tx_int_src_t
*
* \return
* true: interrupt is set
* false: interrupt is not set
*
* \funcusage
* \snippet mixer/snippet/main.c snippet_Cy_Mixer_Tx_ClearInterrupt
*
*******************************************************************************/
__STATIC_INLINE bool Cy_Mixer_Tx_IsInterruptActive(volatile MIXER_TX_STRUCT_Type * base, cy_stc_mixer_tx_int_src_t intSrc)
{
    bool intActive = false;

    switch (intSrc)
    {
    case CY_MIXER_TX_FIFO_UNDERFLOW:
        intActive = (0UL != (MIXER_TX_STRUCT_INTR_TX(base) & MIXER_MIXER_TX_STRUCT_INTR_TX_FIFO_UNDERFLOW_Msk));
        break;
    case CY_MIXER_TX_IFC_UNDERFLOW:
        intActive = (0UL != (MIXER_TX_STRUCT_INTR_TX(base) & MIXER_MIXER_TX_STRUCT_INTR_TX_IF_UNDERFLOW_Msk));
        break;
    default:
        /* Invalid interrupt source */
        CY_ASSERT_L3(false);
        break;
    }

    return intActive;
}

#endif /* (defined(MIXER0_TX_PRESENT) && (MIXER0_TX_PRESENT == 1)) || (defined(MIXER1_TX_PRESENT) && (MIXER1_TX_PRESENT == 1)) */

/** \} group_mixer_functions */

#if defined(__cplusplus)
}
#endif /* __cplusplus */

#endif /* CY_IP_MXMIXER */

#endif /* __CY_MIXER_H__ */

/** \} group_mixer */

/* [] END OF FILE */
